﻿// Licensed under GNU GPL V2.
// http://sps2010listmanager.codeplex.com/
// (c) 2010 by Daniel Bedarf

using System;
using System.Windows;

namespace Extensions
{
    /// <summary>
    /// a small helper to get easy same message dialogs in the wohle app
    /// </summary>
    public static class WindowExtender
    {

        /// <summary>
        /// Asks yes or no.
        /// </summary>
        /// <param name="Title">The title.</param>
        /// <param name="Message">The message.</param>
        /// <param name="args">The args.</param>
        /// <returns></returns>
        public static bool AskYesNo(string Title, string Message, params object[] args)
        {
            return (MessageBox.Show(string.Format(Message, args), Title, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes);
        }

        /// <summary>
        /// Shows the info.
        /// </summary>
        /// <param name="Message">The message.</param>
        /// <param name="args">The args.</param>
        public static void ShowInfo(string Message, params object[] args)
        {
            MessageBox.Show(string.Format(Message,args), "Info", MessageBoxButton.OK, MessageBoxImage.Information);
        }

        /// <summary>
        /// Shows the warning.
        /// </summary>
        /// <param name="Message">The message.</param>
        /// <param name="args">The args.</param>
        public static void ShowWarning(string Message, params object[] args)
        {
            MessageBox.Show(string.Format(Message,args), "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
        }

        /// <summary>
        /// Shows the error.
        /// </summary>
        /// <param name="Message">The message.</param>
        /// <param name="args">The args.</param>
        public static void ShowError(string Message, params object[] args)
        {
            MessageBox.Show(string.Format(Message,args), "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
        }

        /// <summary>
        /// Shows the exception.
        /// </summary>
        /// <param name="ex">The ex.</param>
        public static void ShowError(Exception ex)
        {
            ShowError(ex.Message);
        }
    }
}
